home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MPW_TOOL / TOOLS / TOOLS_WI / ICON_8 / MEMMON_F / MKSYM.ICN < prev    next >
Text File  |  1990-03-02  |  1KB  |  40 lines

  1. #  Icon program to preprocess color symbol and label definitions into C
  2.  
  3. record colr (sym, char, label)
  4.  
  5. procedure main ()
  6.    colors := []
  7.    err := 0
  8.    ws := ' \t'
  9.    while line := read () do line ? {
  10.       tab (many (ws))
  11.       if ="#" | pos (0) then next    # skip comment line
  12.       sym := tab (upto (ws) | 0)
  13.       tab (many (ws))
  14.       char := tab (upto (ws) | 0)
  15.       tab (many (ws))
  16.       label := tab (upto (ws) | 0)
  17.       if *label > 0 then
  18.          put (colors, colr (sym, char, label))
  19.       else {
  20.          write (&errout, "bad input:\t", line)
  21.          err +:= 1
  22.          }
  23.       }
  24.    if err > 0 then
  25.       stop ("output suppressed due to input errors")
  26.  
  27.    write ("/* created mechanically -- DO NOT EDIT */")
  28.    write ()
  29.    write ("#ifndef NColors");
  30.    every i := 1 to *colors do
  31.       write ("#define ", left (colors[i].sym, 12), right (i-1, 3))
  32.    write ("#define NColors ", *colors)
  33.    write ("#endif\t\t\t\t/* NColors */");
  34.    write ()
  35.    write ("#ifdef Color");
  36.    every i := 1 to *colors do
  37.       write ("Color(",colors[i].sym,",",colors[i].char,",",colors[i].label,")")
  38.    write ("#endif\t\t\t\t/* Color */");
  39.    end
  40.